Skip to content

feat: add validity-check for JWTs#88

Open
jucktnich wants to merge 1 commit intojamdotdev:mainfrom
jucktnich:feature/jwt-time-validity-check
Open

feat: add validity-check for JWTs#88
jucktnich wants to merge 1 commit intojamdotdev:mainfrom
jucktnich:feature/jwt-time-validity-check

Conversation

@jucktnich
Copy link
Contributor

Hi,

this PR introduces a quick info, whether a jwt is currently valid. I would love to get feedback on this, especially on my wording; and if you determine it as good enough, I would be happy to see it merged.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JWT validity checking functionality to the JWT parser utility. It displays a color-coded status message indicating whether a token is valid, expired, not yet valid, or never valid based on the iat, nbf, and exp claims.

Changes:

  • Added validity checking logic that evaluates JWT timestamp claims (iat, nbf, exp)
  • Integrated a visual validity indicator with color-coded backgrounds in the JWT parser UI
  • Added comprehensive unit tests for the new validity checking functionality

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tailwind.config.ts Added safelist for dynamic color classes used in validity status display
pages/utilities/jwt-parser.tsx Integrated validity state and color-coded UI component
components/utils/jwt-parser.utils.ts Implemented validity checking logic with date parsing and state enum
components/utils/jwt-parser.utils.test.ts Added comprehensive tests for new validity checking functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

};
else
return {
message: "Token doesn`t contain a validity period",
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect apostrophe character used. The message uses a backtick (`) instead of a proper apostrophe ('). This should be "Token doesn't contain a validity period" with a straight apostrophe.

Suggested change
message: "Token doesn`t contain a validity period",
message: "Token doesn't contain a validity period",

Copilot uses AI. Check for mistakes.
admin: true,
});
expect(result.signature).toBe("abc123");
expect(result.payload).toEqual({
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test assertion is checking the wrong property. Line 161 should be checking result.validity instead of result.payload. The assertion on line 155-159 already verifies the payload content, and this line should verify the validity property that was added to the return type.

Suggested change
expect(result.payload).toEqual({
expect(result.validity).toEqual({

Copilot uses AI. Check for mistakes.
@@ -46,6 +158,10 @@ describe("decodeJWT", () => {
admin: true,
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected payload is missing the 'iat' field that was added to the test token on line 141. The assertion should include iat: "10000" to match the actual payload structure being tested.

Suggested change
admin: true,
admin: true,
iat: "10000",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments